﻿using ManagementApi.Models;
using Modules.System.Dept;
using Modules.System.Role;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ManagementApi
{
    /// <summary>
    /// 角色局部扩展类
    /// </summary>
    public static partial class RoleExceptions
    {
        /// <summary>
        /// 获取角色下拉tree
        /// </summary>
        /// <param name="roles"></param>
        /// <returns></returns>
        public static IEnumerable<VueTree<int>> AsTrees(this IEnumerable<SysRole> roles)
        {
            List<VueTree<int>> entityTrees = new();
            foreach (var item in roles)
            {
                VueTree<int> entityTree = new()
                {
                    Label = item.Name,
                    Value = item.RoleId,
                    Extend1 = item.IndustryType ?? 0
                };
                entityTrees.Add(entityTree);
            }
            return entityTrees;
        }
    }
}